package com.victor.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.victor.entity.activity_tuikuan.ActJifen;
import com.victor.entity.activity_tuikuan.ActManjian;
import com.victor.entity.activity_tuikuan.ActMiaosha;
import com.victor.entity.activity_tuikuan.ActTuangou;
import com.victor.entity.activity_tuikuan.TuikuanSetup;
import com.victor.entity.partner.PartnerType;
import com.victor.entity.partner.PartnerUser;
import com.victor.entity.partner.food.FoodMeal;
import com.victor.entity.partner.food.FoodMealDayUse;
import com.victor.entity.partner.food.FoodMealKeshou;
import com.victor.entity.partner.food.FoodMealPhoto;
import com.victor.entity.partner.happy.HappyTheme;
import com.victor.entity.partner.happy.HappyThemeKeshou;
import com.victor.entity.partner.happy.HappyThemePhoto;
import com.victor.entity.partner.happy.HappyThemeTime;
import com.victor.entity.partner.hotel.HotelRoom;
import com.victor.entity.partner.hotel.HotelRoomExplain;
import com.victor.entity.partner.hotel.HotelRoomKeshou;
import com.victor.entity.partner.hotel.HotelRoomLabel;
import com.victor.entity.partner.hotel.HotelRoomPhoto;
import com.victor.entity.receive.AppGetFoodEntity;
import com.victor.entity.receive.AppGetHappyEntity;
import com.victor.entity.receive.AppGetHotelEntity;

@Mapper
public interface PartnerDao {

	/**
	 * 获取商户类别
	 * 
	 * @param t_type
	 * @return
	 */
	@Select({ "select * from partner_type where t_type=#{t_type}" })
	List<PartnerType> getPartnerType(@Param("t_type") String t_type);

	/**
	 * 获取合作伙伴商家
	 * 
	 * @param type           用户类型(1.酒店.2.美食. 3娱乐)
	 * @param name           商户名
	 * @param brand          商家品牌
	 * @param account        账号
	 * @param t_id           商户类别id
	 * @param business_state 营业状态（0营业中 1歇业中 2闭店）
	 * @return
	 */
	List<PartnerUser> getPartnerUsers(@Param("type") String type, @Param("name") String name, @Param("brand") String brand, @Param("account") String account, @Param("t_id") String t_id, @Param("business_state") String business_state);

	/**
	 * 获取商家详情
	 * 
	 * @param partnerUserid
	 * @return
	 */
	PartnerUser getPartnerUserXQ(@Param("puid") String puid);

	/**
	 * 批量删除
	 * 
	 * @param puids
	 * @return
	 */
	int batchDeletePartnerUser(@Param("ids") int[] ids);

	/**
	 * 批量冻结
	 * 
	 * @param puids
	 * @return
	 */
	int batchFrozenPartnerUser(@Param("ids") int[] ids);

	/**
	 * 将房间信息添加入数据库并返回酒店房间id
	 * 
	 * @param hotelRoom
	 * @return
	 */
	int addHotelRoom(HotelRoom hotelRoom);

	/**
	 * 添加标签数据
	 * 
	 * @param hotelRoomLabel
	 * @return
	 */
	@Insert({ "insert into hotel_room_label (r_id,l_name,l_content) values (#{r_id},#{l_name},#{l_content})" })
	int addHotelRoomLabel(HotelRoomLabel hotelRoomLabel);

	/**
	 * 添加预定说明
	 * 
	 * @param hotelRoomExplain
	 * @return
	 */
	@Insert({ "insert into hotel_room_explain (r_id,e_explain,e_title) values (#{r_id},#{e_explain},#{e_title})" })
	int addHotelRoomExplain(HotelRoomExplain hotelRoomExplain);

	/**
	 * 添加房间介绍图片
	 * 
	 * @param hotelRoomPhoto
	 * @return
	 */
	@Insert({ "insert into hotel_room_photo (r_id,p_photourl) values (#{r_id},#{p_photourl})" })
	int addHotelRoomPhoto(HotelRoomPhoto hotelRoomPhoto);

	/**
	 * 添加房间介绍图片
	 * 
	 * @param tuikuanSetup
	 * @return
	 */
	@Insert({ "insert into tuikuan_setup (table_name,table_id,proportion_sst,proportion_before12,proportion_after12) values (#{table_name},#{table_id},#{proportion_sst},#{proportion_before12},#{proportion_after12})" })
	int addTuikuanSetup(TuikuanSetup tuikuanSetup);

	/**
	 * 添加团购活动
	 * 
	 * @param actTuangou
	 * @return
	 */
	@Insert({ "insert into act_tuangou (table_name,table_id,tg_price,tg_number,tg_limitedtime,tg_starttime) values (#{table_name},#{table_id},#{tg_price},#{tg_number},#{tg_limitedtime},#{tg_starttime})" })
	int addActTuangou(ActTuangou actTuangou);

	/**
	 * 添加秒杀活动
	 * 
	 * @param actMiaosha
	 * @return
	 */
	@Insert({ "insert into act_miaosha (table_name,table_id,ms_starttime,ms_endtime,ms_price,ms_number) values (#{table_name},#{table_id},#{ms_starttime},#{ms_endtime},#{ms_price},#{ms_number})" })
	int addActMiaosha(ActMiaosha actMiaosha);

	/**
	 * 满减活动
	 * 
	 * @param actManjian
	 * @return
	 */
	@Insert({ "insert into act_manjian (table_name,table_id,mj_totlejine,mj_jine) values (#{table_name},#{table_id},#{mj_totlejine},#{mj_jine})" })
	int addActManjian(ActManjian actManjian);

	/**
	 * 积分兑换
	 * 
	 * @param actJifen
	 * @return
	 */
	@Insert({ "insert into act_jifen (table_name,table_id,jf_jifen) values (#{table_name},#{table_id},#{jf_jifen})" })
	int addActJifen(ActJifen actJifen);

	/**
	 * 将美食套餐添加入数据库并返回id
	 * 
	 * @param foodMeal
	 * @return
	 */
	int addFoodMeal(FoodMeal foodMeal);

	/**
	 * 添加每日可售数量
	 * 
	 * @param foodMealDayUse
	 * @return
	 */
	@Insert({ "insert into food_meal_dayuse (fm_id,day,number,today_num) values (#{fm_id},#{day},#{number},#{today_num})" })
	int addFoodMealDayUse(FoodMealDayUse foodMealDayUse);

	/**
	 * 添加图片
	 * 
	 * @param foodMealPhoto
	 * @return
	 */
	@Insert({ "insert into food_meal_photo (m_id,p_photourl) values (#{m_id},#{p_photourl})" })
	int addFoodMealPhoto(FoodMealPhoto foodMealPhoto);

	/**
	 * 将娱乐项目添加入数据库并返回id
	 * 
	 * @param happyTheme
	 * @return
	 */
	int addHappyTheme(HappyTheme happyTheme);

	/**
	 * 添加娱乐项目图片
	 * 
	 * @param happyThemePhoto
	 * @return
	 */
	@Insert({ "insert into happy_theme_photo (t_id,tp_photourl) values (#{t_id},#{tp_photourl})" })
	int addHappyThemePhoto(HappyThemePhoto happyThemePhoto);

	/**
	 * 添加时间
	 * 
	 * @param happyThemeTime
	 * @return
	 */
	@Insert({ "insert into happy_theme_time (t_id,ti_starttime,ti_endtime) values (#{t_id},#{ti_starttime},#{ti_endtime})" })
	int addHappyThemeTime(HappyThemeTime happyThemeTime);

	/**
	 * 上下架房间-- r_upordowntype --0 上架 1下架
	 * 
	 * @param hotelRoomid
	 * @param r_upordowntype
	 * @return
	 */
	@Update({ "update hotel_room set r_upordowntype=#{r_upordowntype} where r_id=#{hotelRoomid}" })
	int UpOrDownHotelRoom(@Param("hotelRoomid") int hotelRoomid, @Param("r_upordowntype") String r_upordowntype);

	/**
	 * 筛选（根据上下架筛选）--p_id商家id r_upordowntype --0 上架 1下架
	 * 
	 * @param p_id
	 * @param r_upordowntype
	 * @return
	 */
	List<HotelRoom> shaixuanUporDown(@Param("p_id") String p_id, @Param("r_upordowntype") String r_upordowntype);

	/**
	 * 获取房间详情---传房间id
	 * 
	 * @param r_id
	 * @return
	 */
	HotelRoom getHotelRoomXQ(@Param("r_id") String r_id);

	/**
	 * 查询当日是否已经设置可售
	 * 
	 * @param date
	 * @return
	 */
	@Select({ "select * from hotel_room_keshou where r_id=#{r_id} and date=#{date}" })
	HotelRoomKeshou getTodayIsSetup(@Param("date") String date, @Param("r_id") String r_id);

	/**
	 * 删除当日设置
	 * 
	 */
	@Delete({ "delete from hotel_room_keshou  where k_id=#{k_id}" })
	int deleteTodayHotelRoomKeshous(@Param("k_id") Integer k_id);

	/**
	 * 添加新的设置
	 * 
	 * @param hotelRoomKeshou
	 * @return
	 */
	@Insert({ "insert into hotel_room_keshou (r_id,date,keshounumber) values (#{r_id},#{date},#{keshounumber})" })
	int addHotelRoomKeshous(HotelRoomKeshou hotelRoomKeshou);

	/**
	 * 删除房间信息
	 * 
	 * @param r_id
	 * @return
	 */
	int delHotelRoom(@Param("r_id") Integer r_id);

	/**
	 * 修改房间信息
	 * 
	 * @param hotelRoom
	 * @return
	 */
	int updHotelRoom(HotelRoom hotelRoom);

	/**
	 * 删除宾馆图片
	 * 
	 */
	@Delete({ "delete from hotel_room_photo where p_id=#{photo_id}" })
	int delHotelRoomPhoto(@Param("photo_id") String photo_id);

	/** app */
	/**
	 * 查询宾馆列表
	 * 
	 * @param t_id          商户类别表id
	 * @param position_city 市搜索
	 * @param position_area 区搜索
	 * @param h_price_start 价钱搜索开始价格
	 * @param h_price_end   价钱搜索结束价格
	 * @param h_star        星级搜索
	 * @param search        搜索内容
	 * @return
	 */
	List<PartnerUser> appGetHotelList(AppGetHotelEntity appGetHotelList);

	/**
	 * 获取推荐宾馆
	 * 
	 * @param position_city
	 * @return
	 */
	@Select({ "select * from partner_user where position_city=#{position_city} and ifhomepage='1' and type=#{type} LIMIT 0,3" })
	List<PartnerUser> appGetTuijian(@Param("position_city") String position_city, @Param("type") String type);

	/**
	 * 上下架美食商品 upordowntype 0 上架 1下架
	 * 
	 * @param foodMealid
	 * @param upordowntype
	 * @return
	 */
	@Update({ "update food_meal set upordowntype=#{upordowntype} where m_id=#{foodMealid}" })
	int upOrDownFoodMeal(@Param("foodMealid") int foodMealid, @Param("upordowntype") String upordowntype);

	/**
	 * 筛选（根据上下架筛选）--p_id商家id upordowntype --0 上架 1下架
	 * 
	 * @param p_id
	 * @param upordowntype
	 * @return
	 */
	List<FoodMeal> shaixuanUporDownFoodMeal(@Param("p_id") String p_id, @Param("upordowntype") String upordowntype);

	/**
	 * 获取美食详情
	 * 
	 * @param m_id
	 * @return
	 */
	FoodMeal getFoodMealXQ(@Param("m_id") String m_id);

	/**
	 * 美食查询当日是否已经设置可售
	 * 
	 * @param date
	 * @param m_id
	 * @return
	 */
	@Select({ "select * from food_meal_keshou where m_id=#{m_id} and date=#{date}" })
	FoodMealKeshou getTodayIsSetupFoodMeal(@Param("date") String date, @Param("m_id") String m_id);

	/**
	 * 美食删除当日设置
	 * 
	 * @param k_id
	 * @return
	 */
	@Delete({ "delete from hotel_room_keshou  where k_id=#{k_id}" })
	int deleteTodayFoodMealKeshous(@Param("k_id") Integer k_id);

	/**
	 * 美食添加新的可售设置
	 * 
	 * @param foodMealKeshou
	 * @return
	 */
	@Insert({ "insert into hotel_room_keshou (m_id,date,keshounumber) values (#{m_id},#{date},#{keshounumber})" })
	int addFoodMealKeshous(FoodMealKeshou foodMealKeshou);

	/**
	 * 删除美食套餐
	 * 
	 * @param m_id
	 * @return
	 */
	int delFoodMeal(@Param("m_id") Integer m_id);

	/**
	 * 修改美食套餐
	 * 
	 * @param foodMeal
	 * @return
	 */
	int updFoodMeal(FoodMeal foodMeal);

	/**
	 * 删除美食图片
	 * 
	 * @param photo_id
	 * @return
	 */
	@Delete({ "delete from food_meal_photo where p_id=#{photo_id}" })
	int delFoodMealPhoto(@Param("photo_id") String photo_id);

	/**
	 * 上下架娱乐项目 upordowntype 0 上架 1下架
	 * 
	 * @param happyThemeid
	 * @param upordowntype
	 * @return
	 */
	@Update({ "update happy_theme set upordowntype=#{upordowntype} where t_id=#{happyThemeid}" })
	int upOrDownHappyTheme(@Param("happyThemeid") int happyThemeid, @Param("upordowntype") String upordowntype);

	/**
	 * 筛选（根据上下架筛选）--p_id商家id upordowntype --0 上架 1下架
	 * 
	 * @param p_id
	 * @param upordowntype
	 * @return
	 */
	List<HappyTheme> shaixuanUporDownHappyTheme(@Param("p_id") String p_id, @Param("upordowntype") String upordowntype);

	/**
	 * 获取娱乐项目详情
	 * 
	 * @param t_id
	 * @return
	 */
	HappyTheme getHappyThemeXQ(@Param("t_id") String t_id);

	/**
	 * 娱乐项目查询当日是否已经设置可售
	 * 
	 * @param date
	 * @param t_id
	 * @return
	 */
	@Select({ "select * from happy_theme_keshou where t_id=#{t_id} and date=#{date}" })
	HappyThemeKeshou getTodayIsSetupHappyTheme(@Param("date") String date, @Param("t_id") String t_id);

	/**
	 * 娱乐项目删除当日设置
	 * 
	 * @param k_id
	 * @return
	 */
	@Delete({ "delete from happy_theme_keshou  where k_id=#{k_id}" })
	int deleteTodayHappyThemeKeshous(@Param("k_id") Integer k_id);

	/**
	 * 娱乐项目添加新的可售设置
	 * 
	 * @param happyThemeKeshou
	 * @return
	 */
	@Insert({ "insert into happy_theme_keshou (t_id,date,keshounumber) values (#{t_id},#{date},#{keshounumber})" })
	int addHappyThemeKeshous(HappyThemeKeshou happyThemeKeshou);

	/**
	 * 修改娱乐项目
	 * 
	 * @param happyTheme
	 * @return
	 */
	int updHappyTheme(HappyTheme happyTheme);

	/**
	 * 删除娱乐项目图片
	 * 
	 * @param photo_id
	 * @return
	 */
	@Delete({ "delete from happy_theme_photo where tp_id=#{photo_id}" })
	int delHappyThemePhoto(@Param("photo_id") String photo_id);

	/**
	 * 查询美食列表
	 * 
	 * @param appGetFoodEntity
	 * @return
	 */
	List<PartnerUser> appGetFoodList(AppGetFoodEntity appGetFoodEntity);

	/**
	 * 查询娱乐列表
	 * 
	 * @param appGetHappyEntity
	 * @return
	 */
	List<PartnerUser> appGetHappyList(AppGetHappyEntity appGetHappyEntity);

}
